 //
//  HuiYuanListButton.m
//  wangzhe
//
//  Created by 李 佳伟 on 2017/11/29.
//  Copyright © 2017年 李 佳伟. All rights reserved.
//

#import "HuiYuanListButton.h"
#import "JTCSM.h"
#import "UIButton+addPro.h"
CGFloat space = 10;
CGFloat changespace = 10;
@interface HuiYuanListButton (){
    UILabel *titleLabel;
    UILabel *timelabel;
    
    UILabel *moneyLabel;
}

@end

@implementation HuiYuanListButton

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        
        NSString *name = @"月度VIP会员";
        CGRect rect = [df labelHeightWithContent:name height:20 font:16];
        titleLabel = [UILabel initWithFrame:CGRectMake(space, changespace, rect.size.width, rect.size.height) text:name font:16 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(89, 89, 89, 1) backgroundColor:nil];
        [self addSubview:titleLabel];
        
        NSString *tiem = @"12个月会员";
        CGRect tiemrect = [df labelHeightWithContent:tiem height:20 font:14];
        timelabel = [UILabel initWithFrame:CGRectMake(space, KVIEW_Y(titleLabel)+changespace, tiemrect.size.width, tiemrect.size.height) text:@"" font:14 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(89, 89, 89, 1) backgroundColor:nil];
        [self addSubview:timelabel];
        
        moneyLabel = [UILabel initWithFrame:CGRectMake(frame.size.width/2, changespace, frame.size.width/2-space, tiemrect.size.height+changespace+rect.size.height) text:@"" font:16 textAlignment:NSTextAlignmentRight texcolor:RGBACOLOR(227, 72, 40, 1) backgroundColor:nil];
        [self addSubview:moneyLabel];
        
        self.frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, KVIEW_Y(moneyLabel)+changespace);
        
    }
    
    return self;
}

- (void)setvalueWithHuiyuanLevelModel:(HuiyuanLevelModel *)model
{
    
    self.otherContent = model.money;
    self.level = model.level;
    timelabel.text = [NSString stringWithFormat:@"%@个月会员",model.level];
    
    moneyLabel.text = [NSString stringWithFormat:@"¥%.f",[model.money floatValue]];
}

@end
